//
//  MessageController.swift
//  SecretChat
//
//  Created by TimTiger on 16/7/11.
//  Copyright © 2016年 TimTiger. All rights reserved.
//

import UIKit
import SCMessageSDK
import MudFramework



/// 消息管理
public class MessageController: NSObject {
    
    /**
     准备一下要发送给的设备
     
     - parameter deviceTokens: 被推送设备的token
     */
    public class func preparePushWithDeviceTokens(deviceTokens: [String]) {
        PushSender.shareSender().payload.deviceTokens.removeAll()
        PushSender.shareSender().payload.deviceTokens += deviceTokens
    }
    
    /**
     连接推送服务器
     
     - parameter success: 成功
     - parameter failed:  失败
     */
    public class func connectServer(success: ()->Void,failed: (NSError)->Void) {
        PushSender.shareSender().asyncConnect({
            success()
        }) { (error) in
            failed(error)
        }
    }
}

// MARK: - 消息发送
public extension MessageController {
    /**
     发送消息
     
     - parameter messageInfo: 消息字典
     */
    public class func sendMessageInfo(messageInfo: [String: AnyObject],success: ()->Void,failed: (NSError)->Void) {
        PushSender.shareSender().payload.messageInfo = messageInfo
        PushSender.shareSender().push()
    }
}

// MARK: - 消息接收
public extension MessageController {
    /**
     接收消息
     
     - parameter messageInfo: 消息字典
     */
    public class func receivedMessageInfo(messageInfo: [NSObject: AnyObject]) {
        
    }
}